package com.zws.cucumber.expr.unit;

import com.zws.cucumber.expr.ZwsExprFunc;
import com.zws.cucumber.expr.ZwsExprMode;
import com.zws.cucumber.expr.ZwsExprUnit;

import java.util.HashSet;
import java.util.Set;

/**
 * author: zws
 */
public class ZwsExprUnitImpl implements ZwsExprUnit {

    private String name;
    private Set<String> aliases;
    private ZwsExprMode mode;
    private ZwsExprFunc func;

    public ZwsExprUnitImpl(String name, ZwsExprMode mode, ZwsExprFunc func) {
        this(name, new HashSet<>(), mode, func);
    }

    public ZwsExprUnitImpl(String name, Set<String> aliases, ZwsExprMode mode, ZwsExprFunc func) {
        this.name = name;
        this.aliases = new HashSet<>();
        this.aliases.addAll(aliases);
        this.aliases.add(name);
        this.mode = mode;
        this.func = func;
    }

    @Override
    public String name() {
        return name;
    }

    @Override
    public Set<String> aliases() {
        return aliases;
    }

    @Override
    public ZwsExprMode mode() {
        return mode;
    }

    @Override
    public ZwsExprFunc func() {
        return func;
    }

    @Override
    public String toString() {
        return name;
    }
}
